//
//  FLUseragreementViewController.m
//  FeeLing
//
//  Created by 乔光玉 on 2019/1/4.
//  Copyright © 2019年 大仙儿飘. All rights reserved.
//

#import "FLUseragreementViewController.h"

@interface FLUseragreementViewController ()
@property(nonatomic,strong) UILabel * qwertyuLabel;

@property(nonatomic,strong) UIButton * backwertyButton;
@property(nonatomic,strong)UITextView * useragrementTextView;
@end

@implementation FLUseragreementViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor colorWithHexString:@"#2B2D5C"];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    UIView *navview = [[UIView alloc] init];
    navview.frame = CGRectMake(0,0,SCREENWIDTH,64);
    
    navview.backgroundColor =[UIColor colorWithHexString:@"32346A"];
    [self.view addSubview:navview];
    UILabel *label = [[UILabel alloc] init];
    label.frame = CGRectMake(0,30,SCREENWIDTH,25);
    label.text = NSLocalizedString(@"dingyueshuoming", nil);
    label.font = [UIFont fontWithName:@"PingFangSC-Regular" size:18];
    label.textColor = [UIColor blackColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.alpha = 1;
    label.numberOfLines = 0;
    [self.view addSubview:label];
    
    UIButton * back = [UIButton new];
    [back setImage:[UIImage imageNamed:@"返回首页_slices"] forState:UIControlStateNormal];
    back.frame = CGRectMake(12, 27, 30, 30);
    [back addTarget:self action:@selector(backButtonTap) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:back];
    
    
    
    
    
    _useragrementTextView=[[UITextView alloc]init];
    _useragrementTextView.backgroundColor = [UIColor colorWithHexString:@"#24234F"];
    _useragrementTextView.clipsToBounds = YES;
    _useragrementTextView.layer.cornerRadius = 5;
    _useragrementTextView.frame = CGRectMake(15, 84, SCREENWIDTH-30, SCREENHEIGHT-84-20);
    if (SCREENHEIGHT>800) {
        navview.frame = CGRectMake(0,0,SCREENWIDTH,64+20);
        label.frame = CGRectMake(0,30+20,SCREENWIDTH,25);
        back.frame = CGRectMake(12, 27+20, 30, 30);
        _useragrementTextView.frame =CGRectMake(15, 84+20, SCREENWIDTH-30, SCREENHEIGHT-84-20-20);
    }
    _useragrementTextView.font =  [UIFont fontWithName:@"PingFangSC-Regular" size:12];
    _useragrementTextView.textColor = [UIColor colorWithHexString:@"#999999"];
    _useragrementTextView.editable = NO;
    [self.view addSubview:_useragrementTextView];
    
    AVQuery *configQuery = [AVQuery queryWithClassName:@"Ulist"];
    [configQuery findObjectsInBackgroundWithBlock:^(NSArray * _Nullable objects, NSError * _Nullable error) {
        NSArray *appLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
        NSString *languageName = [appLanguages objectAtIndex:0];
        if (objects.count) {
            if ([languageName containsString:@"zh"]) {
                _useragrementTextView.text = objects[0][@"content"];
                
            }else{
                
                _useragrementTextView.text = objects[0][@"contenteng"];
                
            }
            
        }else{
            
            if ([languageName containsString:@"zh"]) {
                _useragrementTextView.text = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"dengyue" ofType:@".txt"] encoding:NSUTF8StringEncoding error:nil];
                
            }else{
                
                _useragrementTextView.text = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"dengyue1" ofType:@".txt"] encoding:NSUTF8StringEncoding error:nil];
                
            }
            
            
            
        }
        
        
    }];
    
    
    
}

-(void)backButtonTap{
    
    [self.navigationController popViewControllerAnimated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
